/*
 * @(#)CollatorComparator.java    Jul 5, 2010
 *
 * Copyright 2009 Nyber Shanghai, Inc. All rights reserved.
 */

package com.lab.util.collection;

import java.text.CollationKey;
import java.text.Collator;
import java.util.Comparator;

import com.lab.Student;

/**
 * Class description goes here.
 *
 * @author nickevin@gmail.com
 * @version Jul 5, 2010 11:12:30 AM
 */

public class LocaleComparator implements Comparator<Student> {

	private Collator collator = Collator.getInstance();

	public int compare(Student a, Student b) {
		if (a == null || b == null) {
			return 0;
		}

		CollationKey ca = collator.getCollationKey(a.getLastName());
		CollationKey cb = collator.getCollationKey(b.getLastName());

		return ca.compareTo(cb);
	}
}
